package banwood.com.xiongfasy.http;

import android.content.Context;

import java.net.MalformedURLException;

import banwood.com.xiongfasy.BASE.Urls;
import banwood.com.xiongfasy.activity.MyApplication;
import cn.shellinfo.serv.comm.CommResponse;
import cn.shellinfo.serv.comm.ParamMap;
import cn.shellinfo.serv.comm.test.ConnClient;

/**
 * Created by Administrator on 2017/5/10 0010.
 */

public class CommonImpl implements CommonLogic {
    private Context mContext;

    public CommonImpl(Context mContext) {
        this.mContext = mContext;
    }

    public static CommonImpl getInstance(Context context){
        if(context==null){
            return new CommonImpl(MyApplication.getContext());
        }
        return new CommonImpl(context);
    }




    @Override
    public ParamMap getLogin(ParamMap paramMap,String processorName) {

        try {
            ConnClient connClient=new ConnClient(Urls.HOST);

            CommResponse cr=connClient.sendData(processorName,paramMap);
            if(cr.getResultCode()==1){
                ParamMap ret=new ParamMap();
                ret.put("ErrMsg",cr.getErrMsg());
                return ret;
            }else if (cr.getResultCode()==0){
                ParamMap ret= (ParamMap) cr.getData();
                return ret;
            }

        } catch (MalformedURLException e) {
            e.printStackTrace();
        }

        return null;
    }
}
